package top.lyc829.mymusic.model.db

import androidx.room.*
import top.lyc829.mymusic.model.bean.Banner

/**
 * @Author lyc
 * @create 2021-07-06 13:46
 */
@Dao
interface BannerDao {

    @Query("SELECT * FROM banner")
    suspend fun getBanners() : List<Banner>

    @Insert
    suspend fun addBanners(banner: List<Banner>)

    @Query("DELETE FROM banner")
    suspend fun clearBanners()

    @Transaction
    suspend fun cacheBanners(banner: List<Banner>) {
        clearBanners()
        addBanners(banner)
    }

}